<html>
<head><meta charset="utf-8"><title>VarError NotPresent add env key · t-libs · Zulip Chat Archive</title></head>
<h2>Stream: <a href="https://rust-lang.github.io/zulip_archive/stream/219381-t-libs/index.html">t-libs</a></h2>
<h3>Topic: <a href="https://rust-lang.github.io/zulip_archive/stream/219381-t-libs/topic/VarError.20NotPresent.20add.20env.20key.html">VarError NotPresent add env key</a></h3>

<hr>

<base href="https://rust-lang.zulipchat.com">

<head><link href="https://rust-lang.github.io/zulip_archive/style.css" rel="stylesheet"></head>

<a name="209685443"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/219381-t-libs/topic/VarError%20NotPresent%20add%20env%20key/near/209685443" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Gustav Lennart Voigt <a href="https://rust-lang.github.io/zulip_archive/stream/219381-t-libs/topic/VarError.20NotPresent.20add.20env.20key.html#209685443">(Sep 10 2020 at 18:02)</a>:</h4>
<p>hi,<br>
I wanted to add the key for VarError::NotPresent if the environment key which caused the error is not present. I was told to talk to the lib team on zulip. this was the pr <a href="https://github.com/rust-lang/rust/pull/76536">https://github.com/rust-lang/rust/pull/76536</a> it was of course rejected :)</p>



<a name="209718417"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/219381-t-libs/topic/VarError%20NotPresent%20add%20env%20key/near/209718417" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Josh Triplett <a href="https://rust-lang.github.io/zulip_archive/stream/219381-t-libs/topic/VarError.20NotPresent.20add.20env.20key.html#209718417">(Sep 10 2020 at 22:39)</a>:</h4>
<p>So, that change can't be made without breaking backwards compatibility. If there's enough value in having such information in the error, in theory you could add a new function that returns a new version of the error struct, and deprecate the old function. But in this case, it's not hard to augment the error with your own additional information.</p>



<a name="209718431"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/219381-t-libs/topic/VarError%20NotPresent%20add%20env%20key/near/209718431" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Josh Triplett <a href="https://rust-lang.github.io/zulip_archive/stream/219381-t-libs/topic/VarError.20NotPresent.20add.20env.20key.html#209718431">(Sep 10 2020 at 22:39)</a>:</h4>
<p>Specifically, you could call the function, and in the case of <code>NotPresent</code>, record the environment variable name you requested.</p>



<a name="209718514"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/219381-t-libs/topic/VarError%20NotPresent%20add%20env%20key/near/209718514" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Josh Triplett <a href="https://rust-lang.github.io/zulip_archive/stream/219381-t-libs/topic/VarError.20NotPresent.20add.20env.20key.html#209718514">(Sep 10 2020 at 22:40)</a>:</h4>
<p>Given that, migrating to a new error type for that information doesn't seem likely to me.</p>



<a name="210316123"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/219381-t-libs/topic/VarError%20NotPresent%20add%20env%20key/near/210316123" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Gustav Lennart Voigt <a href="https://rust-lang.github.io/zulip_archive/stream/219381-t-libs/topic/VarError.20NotPresent.20add.20env.20key.html#210316123">(Sep 16 2020 at 20:27)</a>:</h4>
<p>okay, I expected that answer :) I wrapped it with a custom var function...</p>



<hr><p>Last updated: Aug 07 2021 at 22:04 UTC</p>
</html>